#include "CppInfo.h"

EString CppInfo::Variable::getPrintStr()
{
    EString str;
    str = this->typeName + " " 
        + this->name;
    if (this->userData.isEmpty() == false) 
    {
        str += EString(" G:") + this->userData;
    }
    return str;
}

EString CppInfo::Function::getPrintStr()
{
    EString str;
    str = "Function: ";
    str += this->returnType + " " 
         + this->name + "(" ;

    for(int i = 0 ; i < parameterList.size(); i++)
    {
        str += parameterList[i]->getPrintStr();
    }

    str += ")";

    str += EString("ifPureVirtual=") + EString::number(this->ifPureVirtual) + " ";
    str += EString("G:=") + this->userData;
    str += "\n";
    return str;
}

EString CppInfo::Enum::getPrintStr()
{
    EString str;
    str = "Enmu: ";
    str += this->name + "\n" ;

    for(int i =0; i < this->typeList.size(); i++ )
    {
        str += this->typeList[i] + EString("=") + EString::number(this->valueList[i]) + "\n";
    }

    return str;
}

void CppInfo::Class::copyFrom(ClassPtr c)
{
    this->name = c->name;
    this->parentNameList = c->parentNameList;

    this->constructorList = c->constructorList;
    this->destructorList = c->destructorList;

    this->variableList = c->variableList;
    this->functionList = c->functionList;
    this->enumList = c->enumList;
    this->ifPureVirtual = c->ifPureVirtual;
    this->userData = c->userData;
}

EString CppInfo::Class::getPrintStr()
{
    EString str;
    str = "Class: -----------\n";
    str += this->name + "\n" ;
    str += EString("description=") + this->description+"\n";

    str += "parent=";
    for(int i = 0 ; i < parentNameList.size(); i++)
    {
        str += this->parentNameList[i] +",";
    }

    str += "\n";

    for(int i =0; i < this->constructorList.size(); i++ )
    {
        str += this->constructorList[i]->getPrintStr() + "\n";
    }

    for(int i =0; i < this->destructorList.size(); i++ )
    {
        str += this->destructorList[i]->getPrintStr() + "\n";
    }

    for(int i =0; i < this->variableList.size(); i++ )
    {
        str += this->variableList[i]->getPrintStr() + "\n";
    }

    for(int i =0; i < this->functionList.size(); i++ )
    {
        str += this->functionList[i]->getPrintStr() + "\n";
    }

    for(int i =0; i < this->enumList.size(); i++ )
    {
        str += this->enumList[i]->getPrintStr() + "\n";
    }

    str += EString("ifPureVirtual=") + EString::boolValue(this->ifPureVirtual);
    str += "\n";

    return str;
}

EString CppInfo::CppCollection::getPrintStr()
{
    EString str;
    str = "CppCollection: \n";
    
    for(EMap<EString, ClassPtr>::iterator it = this->mapClassPtr.begin();
            it != this->mapClassPtr.end();
            it++)
    {
        str += it->second->getPrintStr();
    }
    return str;
}
